package vip.xiaonuo.biz.modular.room.provider;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.mybatisflex.core.query.QueryWrapper;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
import vip.xiaonuo.biz.api.BizRoomApi;
import vip.xiaonuo.biz.modular.room.entity.ExmRoom;
import vip.xiaonuo.biz.modular.room.service.ExmRoomService;

@Component
public class BizRoomApiProvider implements BizRoomApi {
    @Inject
    ExmRoomService exmRoomService;

    @Override
    public JSONObject getRoomByIp(String ip) {
        return JSONUtil.parseObj(exmRoomService.getOneRoom(ip));
    }

    @Override
    public String getRoomNameByIp(String ip){
        ExmRoom exmRoom=exmRoomService.getOneRoom(ip);
        if(ObjectUtil.isEmpty(exmRoom))return "未知";
        else return exmRoom.getRoomName();
    }
}
